import { PartialType } from '@nestjs/mapped-types';
import { Admin } from '../entities/admin.entity';
import {
  IsArray,
  IsEmail,
  IsNotEmpty,
  IsOptional,
  IsString,
  IsUUID,
  Length,
} from 'class-validator';
import { CheckPasswordStrength } from '../../../../common/decorators/custom-class-validator.decorator';

export class SaveAdminDto extends PartialType(Admin) {
  @Length(1, 20)
  @IsNotEmpty()
  username: string;

  @IsEmail()
  @IsNotEmpty()
  email: string;

  @IsOptional()
  @IsString()
  @CheckPasswordStrength(4)
  password?: string;

  @IsArray()
  @IsOptional()
  roleIds?: string[];

  @IsUUID()
  @IsOptional()
  id?: string;
}

export class LoginDto {
  @IsNotEmpty()
  password: string;

  @IsNotEmpty()
  @IsEmail()
  email: string;

  @IsNotEmpty()
  captcha: string;
}
